<template>
	<view>
		<fa-navbar title="试题分类"></fa-navbar>
		<view class="content">
			<view class="card-view">
				<view  :style="{'height':'202rpx','background-image':'url('+blockDetail.image+')','background-position': 'center center;', 'background-size': 'cover;', 'background-repeat': 'no-repeat;'}">
				<!-- <u-image :src="blockDetail.image" height="202"></u-image> -->
				</view>
			</view>
			<view class="card-view">
				<view class="title">请选择试题分类</view>
				<view>
					<u-cell-group>
						<block v-for="(item,index) in categoryList" :key="index">
							<u-cell :title="item.name" isLink  @click="openAnswer(item)">
								<u-icon slot="icon" name='list-dot' size="32"></u-icon>
							</u-cell>
						</block>
					</u-cell-group>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		computed: {
			blockDetail(){
				return this.vuex_config.blockList.paperimg || [];
			}
		},
		onLoad(e) {
			this.major_id = e.majorId;
			this.mode = e.mode
			this.getCategorylist()
		},
		data() {
			return {
				categoryList:[],
				major_id:0,
				mode:0
			};
		},
		methods:{
			getCategorylist(){
				this.$api.getExamCategory({params:{major_id:this.major_id}}).then((res)=>{
					this.categoryList = res.data
				})
			},
			openAnswer(item){
				uni.$u.route({
					url: '/pages/question/answer',
					params:{category_id: item.id,mode: this.mode,majorId:this.major_id},
				})
				return
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		padding:208rpx 24rpx 0 24rpx;
		.card-view{
			background-color: #ffffff;
			border-radius: 20rpx;
			padding: 24rpx;
			margin-bottom: 24rpx;
			.title{
				padding: 24rpx 0;
				font-size: 32rpx;
				font-weight: 600;
				color: #333333;
			}
		}
	}
</style>
